﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class SiteInfo_Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            try
            {
                int id = int.Parse(Request["id"]);
                CMSModel.CMSEntities dal = DAL.DBManager.GetCmsEmtity();

                //var c = dal.SiteInfo.AsQueryable();
                var c = dal.SiteType_SiteInfo.Where(x => x.sid == id);
                int count = c.Count();
                for (int i = 0; i < count; i++)
                {
                    dal.SiteType_SiteInfo.DeleteObject(dal.SiteType_SiteInfo.First(x => x.sid == id));
                    dal.SaveChanges();
                }

                dal.SiteInfo.DeleteObject(dal.SiteInfo.First(x => x.sid == id));
                ClientScript.RegisterStartupScript(GetType(), "bb", "alert('删除成功');document.location='default.aspx';", true);
                dal.SaveChanges();
            }
            catch (Exception ex)
            {
                LogYuMin.LogWriter.GetWriter(LogYuMin.LogFile.error).Write(GetType(), "deleteNewsType", LogYuMin.LogStates.ERROR, ex);
                ClientScript.RegisterStartupScript(GetType(), "aa", "alert('删除失败');document.location='default.aspx';", true);
            }
        }
    }
}